import axios from 'axios'
import env from '../config/env'

let util = {}
util.title = function(title) {
  title = title ? title + ' - Home' : 'iView project'
  window.document.title = title
}

const ajaxUrl =
  env === 'development'
    ? 'http://127.0.0.1:7456'
    : env === 'production' ? 'https://www.url.com' : 'https://debug.url.com'

util.ajax = axios.create({
  baseURL: ajaxUrl,
  timeout: 30000
})
//开发模式环境直接用的当前webpack-server，只支持get模式
util.ajax.request = env == 'development' ? axios.get : axios.post

export default util
